import java.util.*;
public class lk06 {
    public static void main(String[] args) {
        
    }
    public int[] reversePrint(ListNode head) {
        List n1 = new ArrayList<>();
        while(head.next!=null){
            n1.add(head.val);
            head=head.next;
        }
        int n=n1.size();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=(int) n1.get(n-i-1);
        }
        return a;
    }
}
